package com.lzq.springbook.model;

import com.lzq.springbook.enums.ResultStatus;
import lombok.Data;
import org.apache.ibatis.annotations.Delete;

@Data
public class Result<T> {
    private ResultStatus status;
    private String errorMessage;
    private T data;

    public static <T> Result success(T data) {
        Result<T> result = new Result<>();
        result.setStatus(ResultStatus.SUCCESS);
        result.setErrorMessage("");
        result.setData(data);
        return result;
    }

    public static <T> Result fail(String msg) {
        Result<T> result = new Result<>();
        result.setStatus(ResultStatus.FAIL);
        result.setErrorMessage(msg);
        result.setData(null);
        return result;
    }

    public static <T> Result unLogin() {
        Result<T> result = new Result<>();
        result.setStatus(ResultStatus.UNLOGIN);
        result.setErrorMessage("用户未登录");
        result.setData(null);
        return result;
    }

}
